Back to course home
0% completed
Vote For New Content
Appendix
Contact Us
Strings Interleaving
Problem Statement
Given three strings 'm', 'n', and 'p', write a method to find out if 'p' has been formed by interleaving 'm' and 'n'. 'p' would be considered interleaving 'm' and 'n' if it contains all the letters from 'm' and 'n' and the order of letters is preserved too.
Example 1:
Input: m="abd", n="cef", p="abcdef"
Output: true
Explanation: 'p' contains all the letters from 'm' and 'n' and preserves their order too.
Example 2:
Input: m="abd", n="cef", p="adcbef"
Output: false
Explanation: 'p' contains all the letters from 'm' and 'n' but does not preserve the order.
Example 3:
Input: m="abc", n="def", p="abdccf"
Output: false
Explanation: 'p' does not contain all the letters from 'm' and 'n'.
Example 4:
Input: m="abcdef", n="mnop", p="mnaobcdepf"
Output: true
Explanation: 'p' contains all the letters from 'm' and 'n' and preserves their order too.
Constraints:
0 <= m.length, n.length <= 1000 <= p.length <= 200m,n, andpconsist of lowercase English letters.
Try it yourself
Try solving this question here:
Java
Saved to Cloud
. . . .
Solution: Edit Distance
Solution: Strings Interleaving
Mark as Completed
On this page
Problem Statement
Try it yourself